﻿/**
 * @copyright Copyright 2009 Structured Solutions
 * @license http://www.codeplex.com/ShippingAgent/license Microsoft Public License (Ms-PL)
 * @version 3.2
 */

using System;
using System.Collections.Generic;

namespace StructuredSolutions.ShippingAgent
{
    public class PackageList : List<BVSoftware.Bvc5.Core.Shipping.Package>
    {
        public decimal GetTotalQuantity(string bvin)
        {
            var quantity = 0m;
            foreach (var bvPackage in this)
            {
                foreach (var bvPackageitem in bvPackage.Items)
                {
                    if (bvPackageitem.LineItemBvin.Equals(bvin, StringComparison.InvariantCultureIgnoreCase))
                        quantity += bvPackageitem.Quantity;
                }
            }
            return quantity;
        }
    }
}